﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;

namespace AMDev.BNET.ClientAPI.WoW
{
    /// <summary>
    /// Represents a World of Warcraft realm, exposing all the realm available information.
    /// </summary>
    [DataContract]
    public sealed class WoWRealm
        : ClientObservableObject
    {        
        #region Fields

        private String realmType;
        private String battlegroup;
        private String population;
        private String name;
        private String timezone;
        private String locale;
        private bool queue;
        private bool isUp;

        #endregion

        #region Properties

        [DataMember(Name = "type")]
        public String RealmType
        {
            get
            {
                return this.realmType;
            }
            set
            {
                this.SetProperty(ref this.realmType, value);
            }
        }

        [DataMember(Name = "population")]
        public String Population
        {
            get
            {
                return this.population;
            }
            set
            {
                this.SetProperty(ref this.population, value);
            }
        }

        [DataMember(Name = "name")]
        public String Name
        {
            get
            {
                return this.name;
            }
            set
            {
                this.SetProperty(ref this.name, value);
            }
        }

        [DataMember(Name = "battlegroup")]
        public String Battlegroup
        {
            get
            {
                return this.battlegroup;
            }
            set
            {
                this.SetProperty(ref this.battlegroup, value);
            }
        }

        [DataMember(Name = "timezone")]
        public String Timezone
        {
            get
            {
                return this.timezone;
            }
            set
            {
                this.SetProperty(ref this.timezone, value);
            }
        }

        [DataMember(Name = "locale")]
        public String Locale
        {
            get
            {
                return this.locale;
            }
            set
            {
                this.SetProperty(ref this.locale, value);
            }        
        }

        [DataMember(Name = "status")]
        public bool IsUp
        {
            get
            {
                return this.isUp;
            }
            set
            {
                this.SetProperty(ref this.isUp, value);
            }
        }

        [DataMember(Name = "queue")]
        public bool Queue
        {
            get
            {
                return this.queue;
            }
            set
            {
                this.SetProperty(ref this.queue, value);
            }
        }

        #endregion        

        #region Methods

        public override string ToString()
        {
            return this.ToString(false);
        }

        public string ToString(bool showStatus)
        {
            StringBuilder realmStatus = null;

            if (showStatus)
            {
                realmStatus = new StringBuilder();
                realmStatus.Append(this.Name);
                realmStatus.Append(" - ");
                realmStatus.Append(this.RealmType);
                realmStatus.Append(" - ");
                realmStatus.Append(this.Population);
                realmStatus.Append(" - ");
                realmStatus.Append(this.Battlegroup);
                return realmStatus.ToString();
            }
            else            
                return this.Name;
            
        }

        #endregion
    }
}
